<template>
  <div class="error-page">
    <div class="error-container">
      <div class="error-content">
        <!-- 404图标 -->
        <div class="error-icon">
          <el-icon size="120" color="#8590a6">
            <QuestionFilled />
          </el-icon>
        </div>
        
        <!-- 错误信息 -->
        <div class="error-info">
          <h1 class="error-title">404</h1>
          <h2 class="error-subtitle">页面不存在</h2>
          <p class="error-description">
            抱歉，你访问的页面不存在或已被删除
          </p>
        </div>
        
        <!-- 操作按钮 -->
        <div class="error-actions">
          <el-button type="primary" size="large" @click="goHome">
            <el-icon><HomeFilled /></el-icon>
            返回首页
          </el-button>
          <el-button size="large" @click="goBack">
            <el-icon><Back /></el-icon>
            返回上页
          </el-button>
        </div>
        
        <!-- 推荐链接 -->
        <div class="error-suggestions">
          <h3>你可能想要：</h3>
          <div class="suggestion-links">
            <router-link to="/question" class="suggestion-link">
              <el-icon><QuestionFilled /></el-icon>
              浏览问题
            </router-link>
            <router-link to="/article" class="suggestion-link">
              <el-icon><Document /></el-icon>
              阅读文章
            </router-link>
            <router-link to="/topic" class="suggestion-link">
              <el-icon><CollectionTag /></el-icon>
              发现话题
            </router-link>
            <router-link to="/search" class="suggestion-link">
              <el-icon><Search /></el-icon>
              搜索内容
            </router-link>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import {useRouter} from 'vue-router'

const router = useRouter()

// 返回首页
const goHome = () => {
  router.push('/')
}

// 返回上一页
const goBack = () => {
  if (window.history.length > 1) {
    router.back()
  } else {
    router.push('/')
  }
}
</script>

<style lang="scss" scoped>
.error-page {
  min-height: 100vh;
  background: $background-gray;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.error-container {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.error-content {
  background: $background-color;
  border-radius: $border-radius-large;
  padding: 60px 40px;
  box-shadow: $shadow-light;
}

.error-icon {
  margin-bottom: 32px;
  opacity: 0.6;
}

.error-info {
  margin-bottom: 40px;
}

.error-title {
  font-size: 72px;
  font-weight: 700;
  color: $primary-color;
  margin: 0 0 16px 0;
  line-height: 1;
}

.error-subtitle {
  font-size: 24px;
  font-weight: 600;
  color: $text-color;
  margin: 0 0 16px 0;
}

.error-description {
  font-size: 16px;
  color: $text-secondary;
  margin: 0;
  line-height: 1.6;
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 40px;
}

.error-suggestions {
  border-top: 1px solid $border-light;
  padding-top: 32px;
  
  h3 {
    font-size: 18px;
    color: $text-color;
    margin: 0 0 20px 0;
  }
}

.suggestion-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.suggestion-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: $background-light;
  border-radius: $border-radius-medium;
  text-decoration: none;
  color: $text-secondary;
  transition: all 0.2s ease;
  
  &:hover {
    background: $primary-color;
    color: white;
    transform: translateY(-2px);
    box-shadow: $shadow-medium;
  }
  
  .el-icon {
    font-size: 24px;
  }
  
  span {
    font-size: 14px;
    font-weight: 500;
  }
}

@media (max-width: 768px) {
  .error-content {
    padding: 40px 20px;
  }
  
  .error-title {
    font-size: 48px;
  }
  
  .error-subtitle {
    font-size: 20px;
  }
  
  .error-actions {
    flex-direction: column;
    align-items: center;
    
    .el-button {
      width: 200px;
    }
  }
  
  .suggestion-links {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .suggestion-link {
    padding: 16px 12px;
    
    .el-icon {
      font-size: 20px;
    }
    
    span {
      font-size: 13px;
    }
  }
}
</style>
